package com.hk.settings.test;
public class test2 {
    public static void main(String args[]) {
        int i = 10;
        int two[];
        two = new int[32];
        int ans[];
        ans = new int[32];
        if(i>0)
        {
            int size = 0;
            do {
                two[size++] = i % 2;
                i /= 2;
            } while (i != 0);
            for (int j = 0; j < size; j++) {
                ans[31 - j] = two[j];
            }
            for (int j = 0; j < 32; j++) {
                System.out.print(ans[j]);
            }
        }
        else if(i<0) {
            i = i * (-1);
            int size = 0;
            do {
                two[size++] = i % 2;
                i /= 2;
            } while (i != 0);
            for (int j = 0; j < size; j++) {
                ans[31 - j] = two[j];
            }
            for (int j = 1; j < 32; j++) {
                ans[j] = 1 - ans[j];
            }
            ans[0] = 1;
            for (int j = 31; j > 0; j--) {
                if (ans[j] == 1) {
                    ans[j] = 0;
                } else {
                    ans[j] = 1;
                    break;
                }
            }
            for (int j = 0; j < 32; j++) {
                System.out.print(ans[j]); //输出
            }
        }
        else { //当i为0时
            for (int j = 0; j < 32; j++) {
                System.out.print(ans[j]);

            }
        }
    }
}
